//package com.supermap.gwfs.datashare.main;
//
//import org.dom4j.Document;
//import org.dom4j.DocumentException;
//import org.dom4j.Element;
//import org.dom4j.io.SAXReader;
//
//import java.io.*;
//import java.net.HttpURLConnection;
//import java.net.MalformedURLException;
//import java.net.URL;
//import java.util.List;
//
//import org.codehaus.xfire.client.Client;
//
//public class WebServiceClient {
//
//    public static void main(String[] args) throws IOException, DocumentException {
//        //httpPost();
//        URL url = null;
//        Client c = null;
//        try {
//            url = new URL("http://localhost:8080/GWFS_GridDataShareService/ws/dataShare.wsdl");
//            c =new Client(url);
//            Object[] o=c.invoke("XXZX_GRID_GetWeatherPhenomenaWithStationId", new Object[]{"{stationId:\"57333\",origin:\"CENTRAL\",sequenceValue:\"08\",forecastDate:\"2017-11-02\",forecastValidStart:\"3\",forecastValidEnd:\"72\",forecastFileVersion:\"manual\",interval:3}"});
//
//            System.out.println(o[0].toString());
//        } catch (MalformedURLException e) {
//            e.printStackTrace();
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//    }
//
//    private static void httpPost() throws IOException, DocumentException {
//        //第一步：创建服务地址，不是WSDL地址
//        URL url = new URL("http://localhost:8080/GWFS_GridDataShareService/ws");
//        //第二步：打开一个通向服务地址的连接
//        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
//        //第三步：设置参数
//        //3.1发送方式设置：POST必须大写
//        connection.setRequestMethod("POST");
//        //3.2设置数据格式：content-type
//        connection.setRequestProperty("content-type", "text/xml;charset=utf-8");
//        //3.3设置输入输出，因为默认新创建的connection没有读写权限，
//        connection.setDoInput(true);
//        connection.setDoOutput(true);
//
//        String filePath = System.getProperty("user.dir") + "/client/weather_param_type.xml";
//        //第四步：组织SOAP数据，发送请求
//        String soapXML = getXML(filePath);
//        OutputStream os = connection.getOutputStream();
//        os.write(soapXML.getBytes());
//        //第五步：接收服务端响应，打印
//        int responseCode = connection.getResponseCode();
//        if (200 == responseCode) {//表示服务端响应成功
//            InputStream is = connection.getInputStream();
//
//
//            SAXReader reader = new SAXReader();
//            //fis = new FileInputStream(new File(ReadXML.class.getClassLoader().getResource("weather.xml").getPath()));
//            Document doc = reader.read(is);
//            Element root = (Element) doc.getRootElement().elements().get(1);
//            if (root.elements().size() < 0) {
//                System.out.println("NoData");
//                return;
//            }
//            List<Element> resultList = root.elements();
//            for (Element result: resultList) {
//                System.out.println(result.attributeValue("ns2:status"));
//                System.out.println(result.attributeValue("ns2:nsg"));
//                System.out.println(result.attributeValue("ns2:data"));
//            }
//
//
//            is.close();
////            isr.close();
////            br.close();
//        }
//
//        os.close();
//    }
//
//    /**
//     * @param filePath
//     * @return
//     */
//    public static String getXML(String filePath) {
//        StringBuffer content = new StringBuffer();
//        File file = new File(filePath);
//        BufferedReader reader = null;
//        try {
//            reader = new BufferedReader(new FileReader(file));
//            String tempString = null;
//            while ((tempString = reader.readLine()) != null) {
//                content.append(tempString);
//            }
//            reader.close();
//        } catch (IOException e) {
//            e.printStackTrace();
//        } finally {
//            if (reader != null) {
//                try {
//                    reader.close();
//                } catch (IOException e1) {
//                }
//            }
//        }
//        return content.toString();
//    }
//}